package cate.game.role.pvp.guildwar.msg;

import cate.common.table.d.GDFight;
import cate.game.GameBody;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgOutput;
import cate.game.client.msg.id.MsgIdBGuildWar;
import cate.game.pvp.guildwar.data.GWGuildProfile;
import cate.game.pvp.guildwar.data.GuildWar;
import cate.game.pvp.guildwar.data.GuildWarFightSide;
import cate.game.pvp.guildwar.data.base.GuildWarTimeTable;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "公会战-基础数据 の 返回")
public class GuildWarBaseResp implements MsgOutput {

    @NoteField("数据准备好")
    public boolean dataReady;

    @NoteField("赛季开始时间")
    public long startTime;

    @NoteField("赛季结束时间")
    public long endTime;

    @NoteField("时间表")
    public GuildWarTimeTable timeTable;

    @NoteField("总场次")
    public int total;

    @NoteField("总胜利场次")
    public int totalWin;

    @NoteField("赛季积分")
    public int point;

    @NoteField("连胜次数")
    public int winningSteak;

    @NoteField(value = "排名",detail = "非实时")
    public int rank;

    @NoteField("是否匹配成功")
    public boolean match;

    @NoteField(value = "本轮对手",detail = "如果匹配成功但是为null说明是轮空")
    public GWGuildProfile enemy;

    @NoteField(value = "胜者",detail = "如果是0就是未分胜负")
    public byte winner;

    public GuildWarBaseResp() {
    }

    public GuildWarBaseResp(GameBody game, GuildWar war) {
        this.dataReady = game.pvp.guildWar.getDataManager().isDataReady();
        this.startTime = game.pvp.guildWar.getDataManager().getKv().startTime;
        this.endTime = game.pvp.guildWar.getDataManager().getKv().endTime;
        this.timeTable = game.pvp.guildWar.getDataManager().getKv().timeTable;
        this.total = war.total;
        this.totalWin = war.totalWin;
        this.point = war.point;
        this.winningSteak = war.winningSteak;
        this.rank = war.rank;
        this.match = war.match;
        GuildWarFightSide enemySide = war.field.getSide(GDFight.Team.B);
        if (enemySide != null && !enemySide.isEmpty()) {
            enemy = enemySide.profile;
        }
        this.winner = war.field.winner;
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBGuildWar.BASE_RESP;
    }
}
